/*
 * Project: BoboDesignPattern
 * 
 * File Created at 2019年8月3日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package test.net;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Type ServerSocketBlocking
 * @Desc
 * @author 52489
 * @date 2019年8月3日
 * @Version V1.0
 */
public class ServerSocketBlocking {
    static byte[] bytes = new byte[1024];

    public static void main(String[] args) {
        try {
            ServerSocket serverSocket = new ServerSocket();
            serverSocket.bind(new InetSocketAddress(8888));
            while (true) {
                System.out.println("wait connect");
                Socket socket = serverSocket.accept();
                System.out.println("conn success");
                System.out.println("wait data");
                int read = socket.getInputStream().read(bytes);
                String content = new String(bytes);
                System.out.println(content);
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}
